<?php
$memberId = $_POST['member_id'];
$trade_status = $_POST['trade_status'];
$mysign =$_POST['mysign'];
require_once("cod.config.php");

$cod_verify=new CodVerify($cod_config['key']);
$verify_result = $cod_verify->md5Verify($memberId.$trade_status,$mysign);
if ($trade_status=='SUCCESS'&&$verify_result){
    //=========发优惠券=========
    //获取是否需要返红包
    include_once($this->config["webroot"]."/module/micro_shop/includes/plugin_coupons_class.php");
    $couponsObj = new Coupons();
    $couponsObj->createOnePackage($memberId, 10);    //发放优惠券
    echo "success";		//请不要修改或删除
}else{

    ////验证失败
    echo "fail";

    //调试用，写文本函数记录程序运行情况是否正常
    //logResult("这里写入想要调试的代码变量值，或其他运行的结果记录");
}
class CodVerify {

    var $signKey;

    function __construct($signKey){
        $this->signKey=$signKey;
    }



    function md5Verify($prestr, $sign) {
        $prestr = $prestr . $this->signKey;
        $mysgin = md5($prestr);

        if($mysgin == $sign) {
            return true;
        }
        else {
            return false;
        }
    }


}

?>